package io.renren.modules.PCguanli.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.PCguanli.entity.QuestionRpEntity;
import io.renren.modules.PCguanli.service.QuestionRpService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 题库
 *
 * @author zhangdanxiaozu
 * @email dan.zhang@zju.edu.cn
 * @date 2024-07-08 19:12:14
 */
@RestController
@RequestMapping("PCguanli/questionrp")
public class QuestionRpController {
    @Autowired
    private QuestionRpService questionRpService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("PCguanli:questionrp:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = questionRpService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{number}")
    @RequiresPermissions("PCguanli:questionrp:info")
    public R info(@PathVariable("number") Long number){
		QuestionRpEntity questionRp = questionRpService.getById(number);

        return R.ok().put("questionRp", questionRp);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("PCguanli:questionrp:save")
    public R save(@RequestBody QuestionRpEntity questionRp){
		questionRpService.save(questionRp);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("PCguanli:questionrp:update")
    public R update(@RequestBody QuestionRpEntity questionRp){
		questionRpService.updateById(questionRp);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("PCguanli:questionrp:delete")
    public R delete(@RequestBody Long[] numbers){
		questionRpService.removeByIds(Arrays.asList(numbers));

        return R.ok();
    }

}
